'''
@Company: TWL
@Author: xue jian
@Email: xuejian@kanzhun.com
@Date: 2019-10-03 16:27:30
@LastEditTime: 2019-11-03 13:05:00
'''
import src.point as po
import os

class Line(object):
    def __init__(self, path, label):
        self.path = path
        self.label = label
        self.overlapf = []   #the every line of parameter for ta = 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000
        self.rand_overlap = []
        self.order = []
        # self.gap = []
        if self.path[-1] != '/':
            self.path += '/'

    def read(self):
        for dir in os.listdir(self.path):
            dir = self.path + dir
            # print(dir)
            if os.path.isdir(dir):
                # print(len(self.path))
                # print(len(dir))
                print(dir)
                # print(dir[len(self.path):])
                self.order.append(int(dir[len(self.path):]))
                point  = po.Point(dir)
                point.read_all()
                self.overlapf.append(point.get_overlapf())
                if dir[-1] == '1':
                    self.gap = point.get_gap()
                self.rand_overlap.append(point.get_rand_overlapf())
        self.overlapf = [x for y, x in sorted(zip(self.order, self.overlapf))]
        self.rand_overlap = [x for y, x in sorted(zip(self.order, self.rand_overlap))]
        self.order.sort()
